package com.prs.crm.dao.oa.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.oa.PictureNewsCollectDao;
import com.prs.crm.domain.oa.PictureNews;
import com.prs.crm.domain.oa.PictureNewsCollect;
import com.prs.crm.domain.oa.PictureNewsReceive;

public class PictureNewsCollectDaoImpl extends BaseDaoImpl<PictureNewsCollect> implements PictureNewsCollectDao{

	@Override
	public PictureNewsCollect getPictureNewsCollectByPicture(
			PictureNews pictureNews) {
		Criteria criteria=this.getSession().createCriteria(PictureNewsCollect.class);
		criteria.add(Restrictions.eq("pictureNews", pictureNews));
		List re=criteria.list();
		if (re.size()!=0 || re!=null) {
			return (PictureNewsCollect) re.get(0);
		}else{
			return null;
		}
	}

	@Override
	public PictureNewsCollect getPictureNewsCollectByPictureReceive(
			PictureNewsReceive pictureNewsReceive) {
		Criteria criteria=this.getSession().createCriteria(PictureNewsCollect.class);
		criteria.add(Restrictions.eq("pictureNewsReceive", pictureNewsReceive));
		List re=criteria.list();
		if (re.size()!=0 || re!=null) {
			return (PictureNewsCollect) re.get(0);
		}else{
			return null;
		}
	}

}
